﻿using System;
using System.Collections.Generic;
using System.Web;
using Demo.Model;
using Pampa.MVC.Fluent.Crud;
using Pampa.MVC.Fluent.Grid;

namespace Pampa.MVC.Models
{
    public class CustomerGridConfig : CustomGridConfig<Customer>
    {
        public override void Init()
        {
            // columns
            AddNumberColumn(c => c.ID, "Code").IdColumn().Hidden();
            AddStringColumn(c => c.LastName, "Last Name").OrderByAscending();
            AddStringColumn(c => c.FirstName, "First Name").OrderByAscending();
            AddStringColumn(c => c.Email, "Email");
            AddStringColumn(c => c.BirthDate, "BirthDate").Format("dd/MM/yyyy");
            AddStringColumn(c => c.Nationality.Description, "Nationality").NotElegible();
            AddBoolColumn(c => c.Active, "Active");
            AddNumberColumn(c => c.Limit, "Limit");
            AddStringColumn(c => c.Address.City.Description, "City");

            // quick filters
            AddQuickFilter(c => c.LastName).StartsWith().Text().Label("Last Name");
            AddQuickFilter(c => c.BirthDate).GraterEqual().DatePicker("BirthDateFrom").Label("BirthDate (From)");
            AddQuickFilter(c => c.BirthDate).LessEqual().DatePicker("BirthDateTo").Label("BirthDate (To)");
            AddQuickFilter(c => c.Nationality.ID).Equal().EntitySelector<Country>().Label("Nationality").EmptyText("Seleccione...");
            AddQuickFilter(c => c.Type.ID).Equal().EntityDropDown<CustomerType>().Label("Type").EmptyText("Seleccione...");

            // actions
            AddEditAction().MethodName("editCustomer");
            AddDeleteAction().MethodName("deleteCustomer");
        }
    }
}
  